\n\n\n \n \n
\nSesion 11\n
\n
\n \n \n \n \n\n \n\n
\n
\n
Sesion 11\n
The Document Object Model
-DOM-
\n \n
\n \n \n \n
\n \n\n Adding JS to the web
\n\n \n
\n
\n Adding from the onload on the body tag
\nWe can add JavaScript in the body with onload, we'll write our code into the double quotes,\n but the onload don't suport functions or advanced js, like the next example:
\n\n \n \n\n <body onload=\"alert('Hello from the body onload!')\">
\n //On load means, wherever the js is, it's called\n \n\n \n Adding from the script tag
\nYou can add js, insade the html, just adding the tag \"script\", and inside him all your wantend code
\n \n \n\n \n\n \n\n <scrip>
\n //Here you can add your code like this
\n\n function hiScript() {\n alert(\"Hello from the script tag!\");\n }; \n\n
\n </scrip>\n \n \n Adding from an external js file
\nYou can add js, from an external js file, white the script tag, but, adding some atributes.
JUST ONE BEST PRACTICE, the js are adding at the bottom of the body, cause on that don't will be crashed with the inexisting html tags or css, on that place, the js will be played until all the html struture is loaded, and it will give an fast aparience
\n <scrip src=\"./static/js/index.js\" charset=\"utf-8\" ></scrip>\n \n\n \n